package com.yigang.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yigang.dao.ProductImgDao;
import com.yigang.entity.ProductImg;
import com.yigang.service.ProductImgService;
import com.yigang.utils.ResultUtil;
@Service
@Transactional
public class ProductImgServiceImpl implements ProductImgService{

	@Autowired
	private ProductImgDao productImgDao;
	@Override
	public ResultUtil selectProductImgList(Integer page, Integer limit, ProductImg record) {
		// TODO Auto-generated method stub
		PageHelper.startPage(page, limit);
		List<ProductImg> productImg = productImgDao.selectProductImgList(record);
		PageInfo<ProductImg> pageInfo = new PageInfo<ProductImg>(productImg);
		ResultUtil resultUtil = new ResultUtil();
		resultUtil.setCode(0);
		resultUtil.setCount(pageInfo.getTotal());
		resultUtil.setData(pageInfo.getList());
		return resultUtil;
	}

	@Override
	public ResultUtil deleteByPrimaryKey(Integer productimg_id) {
		// TODO Auto-generated method stub
		productImgDao.deleteByPrimaryKey(productimg_id);
		return ResultUtil.ok();
	}

	@Override
	public ResultUtil insertSelective(ProductImg record) {
		// TODO Auto-generated method stub
		productImgDao.insertSelective(record);
		return ResultUtil.ok();
	}

	@Override
	public ResultUtil updateByPrimaryKeySelective(ProductImg record) {
		// TODO Auto-generated method stub
		productImgDao.updateByPrimaryKeySelective(record);
		return ResultUtil.ok();
	}

	@Override
	public ProductImg selectProductImgById(int productimg_id) {
		// TODO Auto-generated method stub
		return productImgDao.selectProductImgById(productimg_id);
	}

	

}
